#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>


extern int get_json_param_value(char *json_str,int *json_len,char *key_val,char *value_val,int *value_len);
extern char * json2xml(char *json_str);
extern int xml2json(const char *xml,const int xml_len,char *json,int json_len);

int main(void)
{


	char str[1024*1024];
	memset(str,0x00,sizeof(str));
	int ch , i = 0;
	FILE *fp = fopen("test.json","rb");
	if(!fp)
	{
		puts("error file");	
		exit(-1);
	}
	while((ch = fgetc(fp)) != EOF)	
	{
		str[i++] = ch;
	}
	int len = 1000;	
	char *key = "requestStateInfo"; 
	char str1[len];	
	get_json_param_value(str,&i,key,str1,&len);
	printf("%s\n",str1);
	fclose(fp);
	
	puts("------------------------------------------------");

	fp = fopen("test.xml","r");
	if(!fp)
	{
		fprintf(stderr,"open file error\n");
		return -1;
	}
	memset(str,0x00,sizeof(str));
	struct stat st;
	memset(&st,0x00,sizeof(st));	
	stat("test.xml",&st);
	fread(str,1,st.st_size,fp);	
	fclose(fp);
	fprintf(stdout,"xml:\n%s\n",str);
	char json[1024];
	memset(json,0x00,sizeof(json));
	len = xml2json(str,strlen(str),json,1024);
	fprintf(stdout,"get json:\n%s\nlen:[%d]",json,len);


	return 0;
	
}
